/**
 * Packet.java
 *
 * @author Philip Kwok
 */


package SSF.OS.OSPF;


import SSF.OS.*;
import SSF.Net.Util.IP_s;


// ========================= class SSF.OS.OSPF.Packet ====================== //
/**
  * This class implements a generic OSPF packet. The following from RFC 2178
  * are not included:
  * 1) OSPF Version number
  * 2) Packet length
  * 3) Checksum
  * 4) Authentication Type
  * 5) Authentication
  */
public class Packet extends ProtocolMessage {

  // ......................... constants ........................... //

  /** Indicates a hello packet. */
  public static final int HELLO      = 1;
  /** Indicates a database description packet. */
  public static final int DATABASE   = 2;
  /** Indicates a link state request packet. */
  public static final int LS_REQUEST = 3;
  /** Indicates a link state update packet. */
  public static final int LS_UPDATE  = 4;
  /** Indicates a link state acknowledgement packet. */
  public static final int LS_ACK     = 5;
  
  // ........................ member data .......................... //

  /** The type of this Packet. */
  public int typ;
  
  /** The identification of the router which sent this packet, chosen as the
    * smallest of the IPaddress of all its interfaces. */
  public int rtrid;
  
  /** The NHI prefix of the sender. */
  public String nh;
  
  /** The NHI address prefix of the AS to which this packet belongs. */
  public String as_nh;

  /** The area to which this packet belongs. */
  public int area_num;
  

  // -------------------------- constructor Packet ------------------------- //
  /**
   * Constructs a packet given type, router ID, area ID.
   */
  public Packet(int t, int routerid, String rtrnh, String asnh, int areano) {
    typ      = t;
    rtrid    = routerid;
    nh       = rtrnh;
    as_nh    = asnh;
    area_num = areano;
  }
  
  // ---------------------------- Packet.toString -------------------------- //
  public String toString() {
    String s = "";
    s = typ + " " + IP_s.IPtoString(rtrid) + " " + nh + " " + as_nh + " " +
        area_num;
    return s;
  }


} // end class Packet
